/**
 * Class for the fields
 * @author jcoston
 */
public class ReswellField {

	private String alternate;
	private String fieldname;
	private boolean isSelected;
	private String op;
	private String right;
	private String constraint;
	
	/**
	 * Constructor for the Fields. 
	 * A Reswell Database contains Reswell Tables which contains Reswell Fields.
	 * @param alt String containing an alternate name to be displayed in the GUI
	 * @param fname String containing the name of the field
	 */
	public ReswellField(String alt, String fname){
		alternate = alt;
		fieldname = fname;
		right = "";
		op = "";
		constraint = "";
	}
	
	
	/**
     * Return the name of the database
     */
	@Override
    public String toString() {
        return alternate;
    }
	
	/**
	 * Get the alternate name of the field
	 * @return The alternate name
	 */
	public String getAlternate() {
		return alternate;
	}
	
	/**
	 * Set the alternate name of the field
	 * @param alternate String with a more "user friendly" name
	 */
	public void setAlternate(String alternate) {
		this.alternate = alternate;
	}
	
	/**
	 * Get the fieldName
	 * @return The original name of the field
	 */
	public String getFieldname() {
		return fieldname;
	}
	
	/**
	 * Set the fieldName
	 * @param fieldname String with the new name
	 */
	public void setFieldname(String fieldname) {
		this.fieldname = fieldname;
	}
	
	/**
	 * Get the operator
	 * @return operator as a String
	 */
	public String getOp() {
		return op;
	}

	/**
	 * Set the operator
	 * @param op String to set op to
	 */
	public void setOp(String op) {
		this.op = op.trim();
	}

	/**
	 * Get the right number
	 * @return String with the number in right
	 */
	public String getRight() {
		return right;
	}

	/**
	 * Set the right (should be a number)
	 * @param right String to set right to
	 */
	public void setRight(String right) {
		this.right = right.trim();
		constraint = (op + right);
	}

	/**
	 * Return isSelected. 
	 * This value indicates if the field should be displayed in the GUI's table
	 * @return boolean indicating if selected
	 */
	public boolean isSelected() {
		return isSelected;
	}

	/**
	 * Set isSelected
	 * @param isSelected boolean that indicates if the table should be displayed
	 */
	public void setSelected(boolean isSelected) {
		this.isSelected = isSelected;
	}
	
	/**
	 * Get the constraint.
	 * The constraint is a combination of op and right.
	 * @return String containing the constraint.
	 */
	public String getConstraint(){
		return constraint;
	}
	
}
